<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>管理员登录</title>
    <link type="text/css" rel="stylesheet" href="/css/style.css;">
    <script src="/js/jquery-3.3.1/jquery-3.3.1.min.js"></script>
</head>
<body bgcolor="#E7ECEF">
<center>
    <form id="log_Login_action" name="log_Login_action" action="" method="post">
        <table border="0" cellspacing="0" cellpadding="0" style="margin-top:130">
            <tr><td><img src="/images/logon_top.gif"></td></tr>
            <tr height="180">
                <td background="/images/logon_middle.gif" align="center" valign="top">
                    <table border="0" width="90%" cellspacing="0" cellpadding="0">
                        <tr height="50"><td colspan="2"></td></tr>
                        <tr height="30">
                            <td align="right" width="40%">用户名：&nbsp;&nbsp;</td>
                            <td style="text-indent:5"><input type="text" name="user.userName" size="30" value="" id="log_Login_action_user_userName"/></td>
                        </tr>
                        <tr height="30">
                            <td align="right">密&nbsp;&nbsp;码：&nbsp;&nbsp;</td>
                            <td style="text-indent:5"><input type="password" name="user.userPassword" size="30" id="log_Login_action_user_userPassword"/></td>
                        </tr>
                        <tr height="60">
                            <td></td>
                            <td>

                                <input type="button" id="" value="注册" onclick="register()"/>
                                <input type="button" id="" value="登录" onclick="login()"/>

                                <input type="reset" value="重置"/>

                                <a id="log_Login_action_" href="view/indextemp.html">[返回首页]</a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr><td><img src="/images/logon_end.gif"></td></tr>
        </table>
    </form>




</center>
</body>
<script>

    // 用户注册
    function register() {
        var uName = document.getElementById('log_Login_action_user_userName').value;
        var pwd = document.getElementById('log_Login_action_user_userPassword').value;
        if (uName == null || uName == '') {
            alert("用户名不能为空，请输入正确的用户名!")
        }else if (pwd == null || pwd == '') {
            alert("密码不能为空，请输入正确的密码!");
        } else {
            $.ajax({
                url:'/user/reg',
                post:'post',
                data:{
                    userName:uName,
                    userPassword:pwd
                },
                success:function (result) {
                    if (result.code == 200) {
                        location.href = '/pages/admin/view/AdminTemp.html';
                    } else {
                        alert(result.msg)
                    }
                }
            });
        }
    }

<!--    用户登录-->
    function login() {
        var uName = document.getElementById('log_Login_action_user_userName').value;
        var pwd = document.getElementById('log_Login_action_user_userPassword').value;
        if (uName == null || uName == '') {
            alert("用户名不能为空，请输入正确的用户名!")
        }else if (pwd == null || pwd == '') {
            alert("密码不能为空，请输入正确的密码!");
        } else {
            $.ajax({
                url:'/user/login',
                post:'post',
                data:{
                    userName:uName,
                    userPassword:pwd
                },
                success:function (result) {
                    if (result.code == 200) {
                        location.href = '/pages/admin/view/AdminTemp.html';
                    } else {
                        alert(result.msg);
                    }
                }
            });
        }
    }
</script>
</html>